from django.contrib import admin

# Register your models here.
from django.contrib.auth.admin import UserAdmin

from account.models import MyUser
admin.site.site_header = '博客后台'
admin.site.site_title = '博客管理'
class MyUserAdmin(UserAdmin):
    list_display = ['username','email','name','introduce',
                    'company','wx','qq','wb',' photo',
                    'profession',' address','telephone',
                    ]
    #将源码的UserAdmin.fieldsets转换为列表格式
    fieldsets = list(UserAdmin.fieldsets)
    #重写UserAdmin的fieldsets，添加模型字段信息录入
    fieldsets[1]=(('Personal info'),{
        'fields':('email','name','introduce',
                    'company','wx','qq','wb',' photo',
                    'profession',' address','telephone',)
    })
    #根据当前用户设置数据访问权限
    def get_queryset(self, request):
        qs=super().get_queryset(request)
        return qs.filter(id=request.user.id)



admin.site.register(MyUser)